//
//
//
#include <e32base.h>
#include "RocketRequest.h"
#include "RocketResponse.h"

_LIT8( KXmlMimeType, "text/xml" );

CRocketRequest::CRocketRequest(MNetworkEventObervser* aObserver) : CBase()
{
	iNumber = -1;
	iObserver = aObserver;
	this->iUrl.Zero();
	iData	= NULL;
}

CRocketRequest::~CRocketRequest()
{
	delete iData;
}

TPtrC8 CRocketRequest::GetURLPtr()
{
	return iUrl.Left(iUrl.Length());	
}

TPtrC8 CRocketRequest::GetDataPtr()
{
	if(iData)
	{
		TPtr8 ptr(iData->Des());
		return ptr.Left(ptr.Length());
	}
	else
	{
		TBuf8<10> buf;
		buf.Zero();
		return buf.Left(buf.Length());
	}
}

TBool CRocketRequest::Encode()
{
	return ETrue;
}

CRocketResponse::CRocketResponse()
{
	iReturnNumber = -1;
	iNumber = -1;
}

CRocketResponse::~CRocketResponse()
{
	delete iParser;
}

TBool CRocketResponse::Decode(RBuf8& aBuffer)
{
	iParser = Xml::CParser::NewLC(KXmlMimeType, *this);
	iParser->ParseBeginL();
	iParser->ParseL(aBuffer);
	iParser->ParseEndL();
	
	delete iParser;
	iParser = NULL;
	return ETrue;
}

void CRocketResponse::OnStartDocumentL(const Xml::RDocumentParameters& /*aDocParam*/,
							TInt /*aErrorCode*/)
	{
	
	}
void CRocketResponse::OnEndDocumentL(TInt /*aErrorCode*/)
	{
	
	}
void CRocketResponse::OnStartElementL(const Xml::RTagInfo& /*aElement*/,
						const Xml::RAttributeArray& /*aAttributes*/,
						TInt /*aErrorCode*/)
	{
	
	}
void CRocketResponse::OnEndElementL(const Xml::RTagInfo& /*aElement*/, 
									TInt /*aErrorCode*/)
	{
	
	}
void CRocketResponse::OnContentL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
	{
	
	}
void CRocketResponse::OnStartPrefixMappingL(const RString& /*aPrefix*/,
									const RString& /*aUri*/,
									TInt /*aErrorCode*/)
	{
	
	}
void CRocketResponse::OnEndPrefixMappingL(const RString& /*aPrefix*/,
										  TInt /*aErrorCode*/)
	{
	
	}
void CRocketResponse::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/,
											 TInt /*aErrorCode*/)
	{
	
	}
void CRocketResponse::OnSkippedEntityL(const RString& /*aName*/, 
									   TInt /*aErrorCode*/)
	{
	
	}
void CRocketResponse::OnProcessingInstructionL(const TDesC8& /*aTarget*/,
									const TDesC8& /*aData*/,
									TInt /*aErrorCode*/)
	{
	
	}
void CRocketResponse::OnError(TInt /*aErrorCode*/)
	{
	
	}

TAny* CRocketResponse::GetExtendedInterface(const TInt32 /*aUid*/)
	{
		return NULL;
	}
